<?php

class Core_Action_Admin_System_Report_Phpinfo  extends Action_Admin
{
	function execute($request, $initial = false, $script = null)
	{
		if ($initial)
		{
			// http://namnv.younetco.com/v4/fox/admin/systemhealth/phpinfo
			Agilet::setVar('breadcrum',array(
				array(
					'url' => 'admin/system',
					'label' => 'System'
				),
				array(
					'url' => 'admin/system/report',
					'label' => 'Report'
				),
				array(
					'url' => 'admin/report/phpinfo',
					'label' => 'PHP Information'
				)
			));
		}
		
		ob_start();
		phpinfo();
		$source = ob_get_clean();

		preg_match('~<style.+?>(.+?)</style>.+?(<table.+\/table>)~ims', $source, $matches);

		$css = $matches[1];

		$source = $matches[2];

		$css = preg_replace('/[\r\n](.+?{)/iu', "\n#phpinfo \$1", $css);

		//$regex = '/'.preg_quote('<a href="http://www.php.net/">',
		// '/').'.+?'.preg_quote('</a>', '/').'/ims';
		//$source = preg_replace($regex, '', $source);

		// strip images from phpinfo()
		$regex = '/<img .+?>/ims';
		$source = preg_replace($regex, '', $source);

		$regex = '/' . preg_quote('<h2>PHP License</h2>', '/') . '.+$/ims';
		$source = preg_replace($regex, '', $source);

		$source = str_replace('<hr />', '', $source);

		$source = str_replace("module_Zend Optimizer", "module_Zend_Optimizer", $source);

		$request -> response = View::render('core/html/admin/system/report/phpinfo', $data = array('source' => $source));
	}
}
